import open3d as o3d
import numpy as np
pcd = o3d.io.read_point_cloud("../datasets/standford_cloud_data/China dragon.pcd")
print(pcd)  # 输出点云点的个数
obb = pcd.get_oriented_bounding_box()
obb.color = (0, 1, 0)  # obb包围盒为绿色

[center_x, center_y, center_z] = obb.get_center()
print("obb包围盒的中心坐标为：\n", [center_x, center_y, center_z])

vertex_set = np.asarray(obb.get_box_points())
print("obb包围盒的顶点为：\n", vertex_set)

max_bound = np.asarray(obb.get_max_bound())
print("obb包围盒边长的最大值为：\n", max_bound)

min_bound = np.asarray(obb.get_min_bound())
print("obb包围盒边长的最小值为：\n", min_bound)

o3d.visualization.draw_geometries([pcd, obb], window_name="OBB包围盒",
                                  width=1024, height=768,
                                  left=300, top=200,
                                  mesh_show_back_face=False)

